<%--
 *  File:    OrgGroupSummary.jsp
 *  @Author: jianni 
 *  Date:    2001/12/13
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.OrgGroupSummary");  
%>

<% //--------------------------------------  variant and initialization --%>
<%
  	String strModuleName = "OGM";
  	String strTableName = "ovorggroup";
	String privilegeCode = "10107,L105";
%>
  


<%
  	HashMap userinfo = (HashMap)session.getAttribute("userinfo");
%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>


<html>
<head>
<title>OrgGroupSummary</title>
<PageFlow:CheckPageFlow pageName="orggrpsummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	String globalPcCode = ((Integer)pageContext.getAttribute("globalpccode")).toString();
  	Vector allGlobalpccode = (Vector)pageContext.getAttribute("allpccode");
  	Vector orgGroupSummary = (Vector)pageContext.getAttribute("orggrpsummary");
  	if(orgGroupSummary == null)
  	{
    	orgGroupSummary = new Vector();
  	}
  	if(allGlobalpccode == null)
  	{
  		allGlobalpccode = new Vector();
  	}
%>
<script>
parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function clickOrgGroup(id, name, grade, isbottom, parentgrpid)
{
  document.orggroupsummaryform.orggroupid.value = id;
  document.orggroupsummaryform.orggroupname.value = name;
  document.orggroupsummaryform.grade.value = grade;
  document.orggroupsummaryform.isbottom.value = isbottom;
  if(parentgrpid=="")
  {
  	document.orggroupsummaryform.parentgroupid.disabled = true;
  }else
  {
  	document.orggroupsummaryform.parentgroupid.value = parentgrpid;
  }
}
function radiotrue0(rid, vid, vname, vgrade, isbottom, parentgrpid)
{
	clickOrgGroup(vid, vname, vgrade, isbottom, parentgrpid);
	radiotrue(rid);
	parent.down.location.href ="Blank.jsp?<%= OvalTools.randomURL() %>";
}
function page_delete()
{
	var isbot = document.orggroupsummaryform.isbottom.value;
	if(isbot=="N")
	{
		alert("<%= message.getMessageDesc("NOT_LEAF",label.getLabelName("L_Group",false)) %>");
		return;
	}	
  var oid = document.orggroupsummaryform.orggroupid.value;
  if(oid == null || oid.length == 0 || oid == "" || oid == "-1")
    return;
  
  var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
  if(!flag)
    return;
  document.orggroupsummaryform.actionname.value = "delete";
  isRunning = true;
  document.orggroupsummaryform.submit();
}
function page_edit()
{
  var oid = document.orggroupsummaryform.orggroupid.value;
  if(oid == null || oid.length == 0 || oid == "" || oid == "-1")
    return;
  parent.down.location.href = "OrgGroupEdit.jsp?<%= OvalTools.randomURL() %>&orggroupid=" + oid + "&isNew=false&globalpccode=<%=JspHelper.filterNull( globalPcCode)%>&languagecode=<%= strLanguageCode %>";
}
function page_createsub()
{
  var oid = document.orggroupsummaryform.orggroupid.value;
  var oname = document.orggroupsummaryform.orggroupname.value;
  var grade = document.orggroupsummaryform.grade.value;
  if(oid == null || oid.length == 0 || oid == "" || oid == "-1")
    return;
  parent.down.location.href = "OrgGroupEdit.jsp?<%= OvalTools.randomURL() %>&parentgroupid=" + oid + "&parentname=" + oname + "&isNew=true&grade=" + grade + "&globalpccode=<%=JspHelper.filterNull( globalPcCode)%>&languagecode=<%= strLanguageCode %>";
}

function page_createmap()
{
  var oid = document.orggroupsummaryform.orggroupid.value;
  if(oid == null || oid.length == 0 || oid == "" || oid == "-1")
    return;
  parent.down.location.href = "OrgGroupMap.jsp?<%= OvalTools.randomURL() %>&sourceorggroupid=" + oid + "&globalpccode=<%=JspHelper.filterNull( globalPcCode)%>&languagecode=<%= strLanguageCode %>&orgid=<%=JspHelper.filterNull( userinfo.get("orgid") )%>";
}

function page_distribute()
{
 var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE") %>");
  if(!flag)
    return;
  document.orggroupsummaryform.actionname.value = "distribute";
  isRunning = true;
  document.orggroupsummaryform.submit();
}

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(orggroupsummaryform,actionvalue,orderbyname);
  editform.action = "OrgGroupSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
function page_new(){
	var globalpccode = document.orggroupsummaryform.globalpccode.value;
	
	url='OrgGroupEdit.jsp?<%= OvalTools.randomURL() %>&isNew=true&globalpccode='+globalpccode;
	
	parent.down.location.href=url
}
</script>
</head>
<body>
	
	<% //--------------------------------------  hidden form variant --%>	
	<form name="orggroupsummaryform" method="post" action="../../Dispatcher"  target="_parent">
	<input type="hidden" name="pagename" value="orggrpsummary">
    <input type="hidden" name="actionname">   
    <input type="hidden" name="languagecode" value=<%= strLanguageCode %>> 
    
	<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	
	
	<table width="100%" cellspacing="0" border="0" cellpadding="0">
  	<tr> 
    	<td> 
      		<table width="100%" border="0" cellspacing="0">
        	<tr> 
          		<td class="summary_top" colspan="4" ></td>
        	</tr>
        	<tr>
          		<td nowrap><%= label.getLabelName("L_GlobalPCName") + ":" %>
            	<select name="globalpccode">
            	<logic:iterate id="globalpc" collection="<%= allGlobalpccode %>">
              	<% 
                	HashMap gpc = (HashMap)pageContext.getAttribute("globalpc"); 
                	Integer gpccode = (Integer)gpc.get("value");
                	String gpcname = (String)gpc.get("valuename");
                	String strSelect = new String();   
                	if((gpccode.toString()).equalsIgnoreCase(globalPcCode))
                	{
                  		strSelect = "Selected";
                	}
              	%>
              	<option <%=JspHelper.filterNull( strSelect )%>  value = "<%=JspHelper.filterNull( gpccode )%>">
                	<%=JspHelper.filterNull( gpcname )%>
              	</option>
            	</logic:iterate>      
            	</select>           
<%--          		<a href="javascript:page_summary('orderby', 'globalpccode')"><img src="../../images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a>--%>
          		</td>
          		<td>&nbsp;&nbsp;</td>
          		<td>
          			<table>
          				<%@ include file="/inc/SummarySearch.inc" %>
          			</table>
          		</td>	
        	</tr>
      		</table>
      
      
      		<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        	
        	<% //--------------------------------------  summary header --%>
        	<tr class="deepblue-left">
        		<td width="22" class="title_center">&nbsp;</td> 
           		<td width="100" class="title_center" ><a href="javascript:page_summary('orderby','groupcode')"><%= label.getLabelName("L_GroupCode") %></a></td>
          		<td width="120" class="title_center" ><a href="javascript:page_summary('orderby','groupname')"><%= label.getLabelName("L_GroupName") %></a></td>
          		<td width="120" class="title_center" ><a href="javascript:page_summary('orderby','deptname')"><%= label.getLabelName("L_Department") %></a></td>
          		<td class="title_center" ><a href="javascript:page_summary('orderby','groupdesc')"><%= label.getLabelName("L_Description") %></a></td>
          		<td width="120" class="title_center" ><a href="javascript:page_summary('orderby','parentgroupname')"><%= label.getLabelName("L_ParentGroup")%></a></td>
        	</tr>
        
        	<%
             	int i = 0;
             	String strClassType = new String();   
             	boolean bHasChecked = false;    
             	Integer nDefaultOrgGroupId = new Integer(-1); 
             	String nDefaultOrgGroupName = "";
             	Integer nDefaultGrade = new Integer(-1);
             	String nDefaultIsBottom = "";
             	Integer nDefaultParentGroupId = new Integer(-1);
          	%>
          	<logic:iterate id="orggrpsum" collection="<%= orgGroupSummary %>">     
        
        	<%
            	HashMap orggrpMap = (HashMap)pageContext.getAttribute("orggrpsum"); 
            	String strIsDisabled = new String("");
            	String strIsChecked = new String("");
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{                    
              		strClassType = "";
            	}
	            
            	if(!bHasChecked)
            	{
              		strIsChecked = "Checked";                       
              		bHasChecked = true;      
              		nDefaultOrgGroupId = (Integer)(orggrpMap.get("orggroupid"));     
              		nDefaultOrgGroupName = (String)(orggrpMap.get("groupname")); 
              		nDefaultGrade = (Integer)(orggrpMap.get("grade"));  
              		nDefaultIsBottom = (String)(orggrpMap.get("isbottom"));  
              		nDefaultParentGroupId = (Integer)(orggrpMap.get("parentgroupid"));     
            	}
            	i++;   
            
            	String pgrp = (orggrpMap.get("parentgroupid")==null ? "" : (orggrpMap.get("parentgroupid")).toString());                      
          	%>
          	<tr  onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="javascript:radiotrue0('cbox<%=JspHelper.filterNull( String.valueOf(i))%>', '<%=JspHelper.filterNull( orggrpMap.get("orggroupid") )%>', '<%=JspHelper.filterNull( orggrpMap.get("groupname") )%>', '<%=JspHelper.filterNull( orggrpMap.get("grade") )%>', '<%=JspHelper.filterNull( orggrpMap.get("isbottom") )%>', '<%=JspHelper.filterNull( pgrp )%>')"  class="<%=JspHelper.filterNull( strClassType )%>">     
          		<td >
              		<input id="cbox<%=JspHelper.filterNull( String.valueOf(i))%>" type="radio" name="radiobutton" <%=JspHelper.filterNull( strIsDisabled )%> value=<%=JspHelper.filterNull( orggrpMap.get("orggroupid") )%> class="checkbox" <%=JspHelper.filterNull( strIsChecked)%> onClick="javascript:clickOrgGroup('<%=JspHelper.filterNull( orggrpMap.get("orggroupid") )%>', '<%=JspHelper.filterNull( orggrpMap.get("groupname") )%>', '<%=JspHelper.filterNull( orggrpMap.get("grade") )%>', '<%=JspHelper.filterNull( orggrpMap.get("isbottom") )%>', '<%=JspHelper.filterNull( pgrp )%>')">
            	</td>
            	<td>&nbsp;<%=JspHelper.filterNull( orggrpMap.get("groupcode") )%></td>
            	<td>&nbsp;<%=JspHelper.filterNull( orggrpMap.get("groupname") )%></td>
            	<td>&nbsp;<custom:write property="deptname" name="orggrpsum" nbsp="true"/></td>
            	<td>&nbsp;<%=JspHelper.filterNull( orggrpMap.get("groupdesc") )%></td>
            	<%
            		String strParentGroupName = (String)orggrpMap.get("parentgroupname");
            		if(strParentGroupName == null){
            			strParentGroupName="&nbsp;";
            		}

            	%>
            	<td>&nbsp;<%=JspHelper.filterNull( strParentGroupName )%></td>
          	</tr>
          	</logic:iterate> 
        	
        	<% //--------------------------------------  default value --%>       
        	<input type="hidden" name="orggroupid" value="<%=JspHelper.filterNull( nDefaultOrgGroupId )%>">
        	<input type="hidden" name="orggroupname" value="<%=JspHelper.filterNull( nDefaultOrgGroupName )%>">
        	<input type="hidden" name="grade" value="<%=JspHelper.filterNull( nDefaultGrade )%>">
        	<input type="hidden" name="isbottom" value="<%=JspHelper.filterNull( nDefaultIsBottom )%>">   
        	<input type="hidden" name="parentgroupid" value="<%=JspHelper.filterNull( nDefaultParentGroupId )%>"> 
        	
        	<% //--------------------------------------  flipping page --%>
    		<%@ include file="/inc/SummaryAction.inc" %>
    		</table>
    		
    		<% //--------------------------------------  page operation button --%>
      		<table width="100%" cellspacing="0" cellpadding="0">
        	<tr> 
          		<td class="summary_top"></td>
        	</tr>
        	<tr> 
          		<td class="td_center">
            		<a onclick="page_new();"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
            		<a onclick="javascript:page_edit();return false;"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
            		<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a> 
            		<a onclick="page_createsub()"><custom:button type="1" label="L_CreatSubGroup" imgsrc="CreatSubGroup.gif" border="0"/></a>
            		<!-- 
            		<a onclick="page_createmap()"><custom:button type="1" label="L_MapVendorGroup" imgsrc="MapVendorGroup.gif" border="0"/></a>
          			 -->
          <%if(privilegeSet != null && privilegeSet.contains("1010701")){%>
            		<a onclick="page_distribute()"><custom:button type="1" label="L_Distribute" imgsrc="MapVendorGroup.gif" border="0"/></a>
          <%}%>
          		</td>
        	</tr>
      		</table>
    	</td>
  	</tr>
  	</table>
</form>
</body>
</html>


